﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;

namespace FighterClubZero
{
    class SEUtils
    {
        public static bool checkSoftEtherIsInstalled()
        {
            bool flag = false;
            ServiceController ctl = ServiceController.GetServices().FirstOrDefault(s => s.ServiceName == "SEVPNCLIENT");
            if (ctl == null)
                flag = false;
            else
                flag = true;
            return flag;
        }

        public static ServiceController getSeVpnService()
        {
            ServiceController ctl = ServiceController.GetServices().FirstOrDefault(s => s.ServiceName == "SEVPNCLIENT");
            return ctl;
        }
        //NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();//获取本地计算机上网络接口的对象
        //foreach (NetworkInterface adapter in adapters)
        //{
        //    richTextBox1.AppendText("描述：" + adapter.Description);
        //    richTextBox1.AppendText("标识符：" + adapter.Id);
        //    richTextBox1.AppendText("名称：" + adapter.Name);
        //    richTextBox1.AppendText("类型：" + adapter.NetworkInterfaceType);
        //    richTextBox1.AppendText("速度：" + adapter.Speed * 0.001 * 0.001 + "M");
        //    richTextBox1.AppendText("操作状态：" + adapter.OperationalStatus);
        //    richTextBox1.AppendText("MAC 地址：" + adapter.GetPhysicalAddress());
        //    // 格式化显示MAC地址                
        //    PhysicalAddress pa = adapter.GetPhysicalAddress();//获取适配器的媒体访问（MAC）地址
        //    byte[] bytes = pa.GetAddressBytes();//返回当前实例的地址
        //    StringBuilder sb = new StringBuilder();
        //    for (int i = 0; i < bytes.Length; i++)
        //    {
        //        sb.Append(bytes[i].ToString("X2"));//以十六进制格式化
        //        if (i != bytes.Length - 1)
        //        {
        //            sb.Append("-");
        //        }
        //    }
        //    richTextBox1.AppendText("MAC 地址：" + sb);
        //    //获取以太网卡网络接口信息
        //    IPInterfaceProperties ip = adapter.GetIPProperties();
        //    //获取单播地址集
        //    UnicastIPAddressInformationCollection ipCollection = ip.UnicastAddresses;
        //    foreach (UnicastIPAddressInformation ipadd in ipCollection)
        //    {
        //        //InterNetwork    IPV4地址      InterNetworkV6        IPV6地址
        //        //Max            MAX 位址
        //        if (ipadd.Address.AddressFamily == AddressFamily.InterNetwork)
        //            //判断是否为ipv4
        //            label1.Text = label1.Text + ipadd.Address.ToString() + "   ";//获取ip
        //    }
        //    richTextBox1.AppendText("\n");
        //}
        //NetworkInterface adapter = getVPNAdapterByID(vpnAdapterInstance.Id);
    }
}
